package com.agy.filemanager.controller;

import com.agy.filemanager.configuration.MyInterceptor;
import com.agy.filemanager.entity.DcManagerInfo;
import com.agy.filemanager.entity.SessionInfo;
import com.agy.filemanager.service.DcSystemManagerInfoService;
import com.agy.filemanager.service.DcSystemUserFileService;
import com.agy.filemanager.toolClass.Result;
import com.agy.filemanager.toolClass.ResultUtil;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttribute;

import javax.servlet.http.HttpServletRequest;
import java.sql.Date;
import java.util.HashMap;
import java.util.Map;


/**
 * 系统设置-申请调阅
 */
@RestController
@RequestMapping("/UserFile")
public class SystemUserFileController {

    @Autowired
    private DcSystemUserFileService dcSystemUserFileService;

    /**
     * 查询表格数据
     * @param pageNum
     * @param pageSize
     * @param name
     * @return
     */
    @GetMapping("/selectTable")
    public Map<String,Object> selectTable(int pageNum,int pageSize,String name){
        Page page = this.dcSystemUserFileService.selectTable(pageNum,pageSize,name);
        Map<String,Object> map = new HashMap<>();
        map.put("total",page.getTotal());
        map.put("rows",page.getResult());
        return map;
    }

    /**
     * 设置权限
     * @param id
     * @return
     */
    @PostMapping("operateById")
    public Result operateById(@SessionAttribute(MyInterceptor.SESSION_KEY) SessionInfo info, String id, String sign){
        this.dcSystemUserFileService.operateById(id,sign,info);
        return ResultUtil.success("设置成功");
    }
}
